package com.dy.design_pattern_study.mediator_pattern.dome1.impl;

import com.dy.design_pattern_study.mediator_pattern.dome1.Colleague;
import com.dy.design_pattern_study.mediator_pattern.dome1.Mediator;
import lombok.Setter;

/**
 * @CreateBy zhangdingyi
 * @Date 2023-04-23
 * @Content 具体中介者类
 */
public class ConcreteMediator extends Mediator {

    //声明同事对象
    @Setter
    private ConcreteColleague1 colleague1;
    @Setter
    private ConcreteColleague2 colleague2;

    @Override
    public void send(String message, Colleague colleague) {
        //重写发送信息方法，根据具体的对象做出对应的判断来通知不同的对象
        if (colleague.equals(colleague1)){
            colleague2.notifyMessage(message);
        } else {
            colleague1.notifyMessage(message);
        }

    }
}
